<template>
    <div class='form' v-if='rule' >
        <form-create 
            ref="fc" 
            v-model="fApi" 
            :rule="rule" 
            :option="option" 
            >
        </form-create>
    </div>
</template>

<script>
import  jsonMack  from '../json/json.js'
import  'form-create/district/province_city.js'
export default {
    data(){
        return{
            formModel:{},
            rule:jsonMack,
            option:{
                //显示表单重置按钮
                resetBtn:true,
                iframeHelper:true,
				//
                upload:{
                    'beforeUpload':function (res) {
                        console.log(res);
                    }
                },
                //表单提交事件
                onSubmit:function (formData) {
                    alert(JSON.stringify(formData));
                    //按钮进入提交状态
                    $f.btn.loading();
                    //重置按钮禁用
                    $f.resetBtn.disabled();
                    //按钮进入可点击状态
//                    $f.btn.finish();
                    //创建第二个表单
                    $f = that.$formCreate(mock,root);
                },
	            mounted($f){
		            var $m = $f.model();
                    $m.goods_name.value += " now";
	            },
	            //onReload 表单重载是触发 用与更新$f
                onReload($f){
                    console.log($f);
                }
            },
            fApi:{}
        }
    },
    watch:{
        'formData.address':{
            handler:function (n) {
                console.log(n);
            },
            deep:true
        }
    },
    methods:{
        change:function (...arg) {
            console.log(arg);
        }
    },
    mounted:function () {
        console.log(this.fApi);
        var $f = this.fApi;
        //实际开发中记得加 var
        // this.formModel = this.fApi.model();
    }
}
</script>

<style lang="scss" scope>
    .ivu-form{
        text-align:left;
    }
</style>